<?php
			// Use the MiniXML library for easy XML editing
			require_once('minixml/minixml.inc.php');
			
			$host="localhost"; // Host name 
			$username="clevelandclinic"; // Mysql username 
			$password="Radiollaboration"; // Mysql password 
			$db_name="clevelandclinic"; // Database name 
			$con = mysql_connect($host,$username,$password);
			if (!$con)
			{
			  die('Could not connect: ' . mysql_error());
			}
			
			mysql_select_db($db_name, $con);
			$result = mysql_query("SELECT * FROM annotations where image_id=5");
							
			//Make SQL result $row[file_path]
			while($row = mysql_fetch_array($result)){
				$string .=  $row[file_path].",";
		//		echo $row[file_path];
			}
			$string = substr($string, 0, -1); //get rid of the tailing comma!
			$layerArray = split("," , $string);

			$path = 'imageData/Koala.jpg';
			
			header('Content-type: image/svg+xml');
			$outputString .= '<svg xmlns="http://www.w3.org/2000/svg" width="640" height="480" xmlns:xlink="http://www.w3.org/1999/xlink">';
			$outputString .= '<image xlink:href="'.$path.'" width="80%" height="80%" preserveAspectRatio="xMinYMin"/>';
			
			for ($i=0; $i<count($layerArray);$i++){
				$parsedDoc = new MiniXMLDoc();
				$parsedDoc->fromFile($layerArray[$i]);
				$rootEl = $parsedDoc->getRoot();
				$layer =& $rootEl->getElement('g');
				$username = $layer->getText('title");

				$layerData = array(
				


				//echo $layer->toString();
				$outputString .= $layer->toString();
			}
			$outputString .= '</svg>';

			//echo $outputString; //CHANGE THIS ECHO TO AN SVG through PHP SAVE METHOD
			
			$savedSVG = $outputString;
							
			echo $savedSVG;				
			?>


	
